#define _CRT_SECURE_NO_WARNINGS 1

#include<iostream>
#include<vector>

using namespace std;

int maxProfit(vector<int>& prices) {
    int maxv = 0;
    int minprice = 1e9;
    for (auto price : prices)
    {
        maxv = max(maxv, price - minprice);
        minprice = min(price, minprice);
    }
    return maxv;
}

int main()
{
    int arr[] = { 7,1,5,3,6,4 };
    vector<int> v(arr, arr + 6);
    maxProfit(v);
	return 0;
}